package top.houry.redis.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import top.houry.redis.service.ISignService;

import java.time.LocalDate;

@Service
public class SignServiceImpl implements ISignService {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Override
    public void sign(String key, LocalDate date) {
        int offset = date.getDayOfMonth() - 1;
        stringRedisTemplate.opsForValue().setBit(key, offset, true);
    }

    @Override
    public boolean getSignInfo(String key) {
        return Boolean.TRUE.equals(stringRedisTemplate.opsForValue().getBit(key, 22));
    }


}